package com.heyqing.topic.NumArray_0303;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * ClassName:NumArray
 * Package:com.heyqing.topic.NumArray_0303
 * Description:
 *
 * @Date:2024/9/26
 * @Author:Heyqing
 */
public class NumArray {
    private List<Integer> list;

    public NumArray(int[] nums) {
        list = Arrays.stream(nums).boxed().collect(Collectors.toList());
    }

    public int sumRange(int left, int right) {
        int sum = 0;
        for (int i = left; i <= right; i++) {
            sum += list.get(i);
        }
        return sum;
    }
}